Module Installer

    Public Const CountersCategoryName As String = "KanBan PGD Counters"

    Sub Main(ByVal args As String())

        Console.WriteLine("(R)egister Counters?")
        Console.WriteLine("(D)elete Counters?")
        Console.WriteLine("(C)ancel?")

        Select Case (Console.ReadLine().ToLower())
            Case "r"
                Console.WriteLine("Registering Counters...")
                CreateCounters()
            Case "d"
                Console.WriteLine("Deleting Counters")
                DeleteCounters()
            Case "c"
                Exit Sub
            Case Else
                Console.WriteLine("Invalid Choice")
        End Select

        Console.Write("Done")
        Console.ReadLine()

    End Sub

    Private Sub CreateCounters()

        Dim col As New CounterCreationDataCollection()

        Dim totalOperations As New CounterCreationData()
        totalOperations.CounterName = "Total Operations Executed"
        totalOperations.CounterHelp = "Stores the numbre of total requests processed by the System"
        totalOperations.CounterType = PerformanceCounterType.NumberOfItems64

        Dim operationsPerSecond As New CounterCreationData()
        operationsPerSecond.CounterName = "Operations per Second"
        operationsPerSecond.CounterHelp = "Number of operations executed per second"
        operationsPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond64

        Dim averageDuration As New CounterCreationData()
        averageDuration.CounterName = "Average Time per Operation"
        averageDuration.CounterHelp = "Average duration per operation execution"
        averageDuration.CounterType = PerformanceCounterType.AverageTimer32

        Dim averageDurationBase As New CounterCreationData()
        averageDurationBase.CounterName = "Average Time per Operation Base"
        averageDurationBase.CounterHelp = "Average duration per operation execution base"
        averageDurationBase.CounterType = PerformanceCounterType.AverageBase

        col.Add(totalOperations)
        col.Add(operationsPerSecond)
        col.Add(averageDuration)
        col.Add(averageDurationBase)

        If Not PerformanceCounterCategory.Exists(CountersCategoryName) Then
            PerformanceCounterCategory.Create(CountersCategoryName, _
                                              CountersCategoryName, _
                                              PerformanceCounterCategoryType.Unknown, _
                                              col)
        Else
            Console.WriteLine("Counters already exists")
        End If


    End Sub

    Private Sub DeleteCounters()

        If PerformanceCounterCategory.Exists(CountersCategoryName) Then
            PerformanceCounterCategory.Delete(CountersCategoryName)
        End If

    End Sub

End Module
